From: | David McMinn |
Date: | 06 Aug 99 at 08:23:35 |
Subject: | Re: Menus and Hooks |
From: "David McMinn" <D.Mcminn@eee.rgu.ac.uk>
> 1. I'm using a NewMenu structure and CreateMenus(), LayoutMenus() to make
> some menus, and I want to add some keyboard shortcuts for them. I've tried
> using the nm_CommKey field of NewMenu, along with NM_COMMANDSTRING to do
> this, but I can't see a way to add shortcuts like "<A> q" where <A> is the
> Amiga key. Is this the right way to do shortcuts? How can I add the <A>
> graphic?
You just specify the shortcut key, the <A> graphic will be added by Intuition
automatically.
> 2. I'm also using guigfx.library to display pictures on screen, and I'd
> recommend it to anyone. However, I'd like to make a callback hook for it,
> which would enable me to interupt rendering, but I can't manage to get it
> to work.
> I don't really understand the InitHook() function (It's taken from
> <utility/hooks.h>) as it doesn't seem to initialise the h_Entry field. Can
> anyone suggest how I should initialise the Hook structure?
It looks like you are not pointing the h_Entry field at a proper function, so
you'll just be calling a random area of memory. Normally the h_Entry field
specifies a small assembly function which moves the hook parameters (a0, a1,
a2) into the appropriate place for C to use them as parameters for a function.
It then calls the h_SubEntry field, which is the function you want to perform
as the hook.
However, if you have a compiler which lets you specify the registers you want
as parameters, you can skip the assembly part and use the h_Entry field to
point directly to the function you want to use as a hook, as long as you
specify the correct registers for the parameters of the function.
So, you'd have something like this:
ULONG __saveds abortdrawfunc(__reg("a0") struct Hook *hook, __reg("a1") LONG
*object, __reg("a2") LONG *message)
{
}
I can't rememebr if the object is passed in a1 or if it is the message, you may
need to swap a1 and a2. Also, I've used LONGs, but you should use the proper
structure (obviously), which should be specified in the docs somewhere.
then to initialise your hook you would have:
hook->h_Entry = abortdrawfunc; /* You may need to cast this line */
hook->h_Data = userdata;
The C function should be called directly as the hook function.